﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mIE.Calculate
{
    public class LGC_TIM_D29_SAW
    {
        public static double LGC_TIM_D29_SAW_VALUE(string DWG_NO, string PartNo, string FeatValue)
        {
            double TD29 = 0, Tn = 0, Tw1 = 0, Tw2 = 0;
            //得到该号码的尺寸参数
            DataTable dtSize = Common.GetCommon.GetSizeParmList(DWG_NO, PartNo);
            Tn = double.Parse(string.IsNullOrEmpty(FeatValue) ? "0" : FeatValue);
            if (dtSize.Rows.Count > 0)
            {
                Tw1 = double.Parse(string.IsNullOrEmpty(dtSize.Rows[0]["WIDTH_1"].ToString()) ? "0" : dtSize.Rows[0]["WIDTH_1"].ToString());
                Tw2 = double.Parse(string.IsNullOrEmpty(dtSize.Rows[0]["WIDTH_2"].ToString()) ? "0" : dtSize.Rows[0]["WIDTH_2"].ToString());
                if (NumMAX(Tw1, Tw2) <= 1200)
                {
                    TD29 = ((105 * Tn) + 141) / 5;
                }
                else if (NumMAX(Tw1, Tw2) <= 1600)
                {
                    TD29 = ((105 * Tn) + 153) / 4;
                }
                else
                {
                    TD29 = ((105 * Tn) + 164) / 3;
                }
            }
            return TD29;

        }
        private static double NumMAX(double Tw1, double Tw2)
        {
            if (Tw1 > Tw2)
            {
                return Tw1;
            }
            return Tw2;
        }
    }
}
